import React from 'react'
// ===================================================================== Temp
import SearchForm from '#cpt/temp/SearchForm'
import Table from '#cpt/temp/Table'
// ===================================================================== Declare
const { $fn } = window
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		// selectedKeys:[],
		// 搜索表单列表
		forms : [
			{ label: '关键字',			name: 'title' },
			{ label: '消息重要级别',		name: 'level',		type: 'select',	data: this.props.level },
			{ label: '状态',			name: 'is_view',	type: 'select',	data: this.props.status },
			{ label: '消息类型',			name: 'type',		type: 'select',	data: this.props.notice },
		],
	}
	
	model = {}
	
	componentDidMount(){
		this.fetch()
	}
	
	// paging
	fetch = reset => $fn.fetch.call(this,'msg-system/index', { reset })
	
	render(){
		return (
			<>
				{/* 搜索 */}
				{ SearchForm.call(this) }
				{/* 表格 */}
				{ Table.call(this, { cols:this.props.cols, onRow: ({ uuid, user_id }) => $fn.pushTo(this,`detail?uuid=${uuid}&user_id=${user_id}&index=0`) }) }
			</>
		)
	}
}

export default Index